import java.util.Scanner;
import java.util.Arrays;
public class FingString {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int m = input.nextInt();
        int n = input.nextInt();
        input.nextLine();
        if(m < 1 || m > n){
            System.out.println("m is out of range");
            return;
        }else{
            String[] string = new String[n];
            for(int i = 0;i < n;i++){
                string[i] = input.nextLine();
            }
            Arrays.sort(string);
            //System.out.println(m);
            //System.out.println(Arrays.toString(string));
            System.out.println(string[m-1]);
        }

    }
}
